<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>订单信息</title>
<script src="assets/js/iscrollEvent.js"></script>
<style>
    html,
    body{
      height: 100%;
    }
</style>
<script type="text/javascript">
	var app = new EventsList(null, {
		api : '${ctx}/weixin/employee/orderListPage',
		params : {
			page : 1,
			no_record :'您当前还没有订单哦'
		}
	}, initData);
	app.init();

	document.addEventListener('touchmove', function(e) {
		e.preventDefault();
	}, false);
	
	var temp = $.trim($("#temp").html());
	
	function initData(data, type, $list) {
		if (data.rows) {
			$.each(data.rows, function(i, item) {
				var date = new Date(item.statedate.replace(/-/g, "/"));
				var strDate = date.format("M月d日 EEE - HH:mm");
				var stateName = "已服务";
				if (item.state == "10A")
					stateName = "处理服务";
				var payStateName = "已支付";
				if (item.payState != "10A")
					payStateName = "处理支付";
				var div = $(Comm.format(temp, strDate, item.orderNo,
						item.vipName==null?'非会员':item.vipName,item.mdseServiceName,item.serviceContent,stateName,payStateName));
				var $btn = div.find('.service-btn');
				if (item.state != "10A") {
					$btn.prop("disabled", true);
					$btn.addClass("am-btn-default");
					$btn.removeClass("am-btn-landiao");
				}else{
					$btn.click(function(){  
						handlerOrder(this,item.orderInfoId,item.orderScheduleId);  
					});  
				}
				var $payBtn = div.find('.pay-btn');
				if (item.payState == "10A") {
					$payBtn.prop("disabled", true);
					$payBtn.addClass("am-btn-default");
					$payBtn.removeClass("am-btn-landiao");
				}else{
					$payBtn.click(function(){  
						handlerOrder(this,item.orderInfoId,null);  
					});  
				}
				div.appendTo($list);
			});
		}
	}
	
	function handlerOrder(btn,orderInfoId,orderScheduleId){
		var url = "${ctx}/weixin/employee/billingFlow?orderInfoId="+orderInfoId;
    	if (orderScheduleId) {
    		url = url +"&orderScheduleId="+orderScheduleId;
    	}
        window.location.href=url;
	}
</script>
</head>
<body>
	<div id="wrapper" data-am-widget="list_news"
		class="am-list-news am-list-news-default">
		<div class="am-list-news-bd">
			<div class="pull-action loading" id="pull-down">
				<span class="am-icon-arrow-down pull-label" id="pull-down-label">
					下拉刷新</span> <span class="am-icon-spinner am-icon-spin"></span>
			</div>
			<div class="am-list am-g" id="record-list">
				<div class="am-list-item-text">正在加载内容...</div>
			</div>
			<div class="pull-action" id="pull-up">
				<span class="am-icon-arrow-down pull-label" id="pull-up-label">
					上拉加载更多</span> <span class="am-icon-spinner am-icon-spin"></span>
			</div>
		</div>
	</div>
	<div style="display: none" id="temp">
		<div class="am-u-sm-12 am-padding-vertical-sm">
			<div class="am-panel am-panel-landiao">
				<div class="am-panel-hd am-text-bold am-text-left">{0}</div>
				<div class="am-panel-bd am-padding-0">
					<ul class="am-list am-list-static am-margin-0">
						<li>&nbsp;&nbsp;订单编号：{1}</li>
						<li>&nbsp;&nbsp;顾客：{2}</li>
						<li>&nbsp;&nbsp;服务项目：{3}</li>
						<li>&nbsp;&nbsp;服务内容：{4}</li>
						<li>
						<ul class="am-avg-sm-2 btn-ul">
							<li class='am-padding-xs'><button class="service-btn am-btn am-btn-landiao am-radius am-btn-block" type="button">{5}</button></li>
							<li class='am-padding-xs'><button class="pay-btn am-btn am-btn-landiao am-radius am-btn-block" type="button">{6}</button></li>
						</ul>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
